var virualpath = "../../";
//var Demopath = "/MLSMooc/Areas"; //线上
var Demopath = "/Areas"; //本地 
//课程目录
var str = "";
$(function () {
    $.ajax({
        url: virualpath + '/Menu/GetMenuAsync',
        type: 'get',
        async: true,
        dataType: 'json',
        contentType: 'application/json',
        success: function (data) {
                var resultData = data;
                if (resultData != undefined) {
                    for (var i = 0; i < Object.keys(resultData).length; i++) {
                        if (resultData[i].Mid == 0) {
                            str += '<li><a href="' + Demopath + '/MLSMooc/Project.html?/id=' + resultData[i].ResourceId + '" ><p><span>' + resultData[i].Name + '</span><span><b>' + resultData[i].CourseCount + '个知识点</b><b>' + resultData[i].BrowseCount + '人次浏览</b></span></p></a><ul class="two">';
                            for (var j = 0; j < Object.keys(resultData).length; j++) {
                                if (resultData[j].Mid == resultData[i].Id && resultData[j].Type == 2) {
                                    str += '<li><a href="' + Demopath + '/MLSMooc/Course.html?/id=' + resultData[j].ResourceId + ',Proid=' + resultData[i].ResourceId + '" ><p><span>' + resultData[j].Name + '</span></p></a><ul class="three">';
                                    for (var k = 0; k < Object.keys(resultData).length; k++) {
                                        if (resultData[k].Mid == resultData[j].Id && resultData[k].Type == 3) {
                                            str += '<li><a href="wechat.html" ><p><span>' + resultData[k].Name + '</span></p></a></li>';
                                        }
                                        if (k == Object.keys(resultData).length - 1) {
                                            str += "</ul></li>";
                                        }
                                    }
                                }
                               
                                if (j == Object.keys(resultData).length-1) {
                                    str += "</ul></li>";
                                }
                            }

                        }
                    }
                    
                    $("#mainmenu").append(str);
                    $(document).ready(function () {
                        $('.menu li').hover(function () {
                            $(this).children('ul').show();
                            $(this).focus().addClass('focusa')
                        }, function () {
                            $(this).children('ul').hide();
                            $(this).focus().removeClass('focusa')
                        });
                    });
                }
          
        }
    })
       
   
});

	
